home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / QuickTime™ 1.5 interfaces / MoviesFormat.lisp < prev    next >
Encoding:
Text File  |  1994-09-12  |  14.3 KB  |  483 lines  |  [TEXT/CCL2]

  1.  
  2. (in-package :TRAPS)
  3. ; ************************************************************
  4. ; Created: Monday, August 17, 1992 at 5:13 PM
  5. ;  MoviesFormat.p
  6. ;  Pascal Interface to the Macintosh Libraries
  7. ;  Copyright Apple Computer, Inc. 1991, 1992
  8. ;  All rights reserved
  9. ;  03/10/93 bill pulled trackDirectoryArray def out of in-line in MovieDirectory
  10. ;                definition so that the translator could deal.
  11. ; ************************************************************
  12.  
  13. ; $IFC UNDEFINED UsingIncludes
  14. ; $SETC UsingIncludes := 0
  15. ; $ENDC
  16.  
  17. ; $IFC NOT UsingIncludes
  18.  
  19. ; $ENDC
  20.  
  21. ; $IFC UNDEFINED UsingMoviesFormat
  22. ; $SETC UsingMoviesFormat := 1
  23.  
  24. ; $I+
  25. ; $SETC MoviesFormatIncludes := UsingIncludes
  26. ; $SETC UsingIncludes := 1
  27.  
  28. ; $IFC UNDEFINED UsingMovies
  29.  
  30. (require-interface 'MOVIES)     ; $I $$Shell(PInterfaces)Movies.p
  31. ; $ENDC
  32. ; $IFC UNDEFINED UsingImageCompression
  33.  
  34. (require-interface 'IMAGECOMPRESSION); $I $$Shell(PInterfaces)ImageCompression.p
  35. ; $ENDC
  36. ; $SETC UsingIncludes := MoviesFormatIncludes
  37.  
  38. (defconstant $kMovieVersion 0)  ;  version number of the format here described 
  39.  
  40. ; ****************************************
  41. ; *
  42. ; *   General Types -
  43. ; *        These types are used in more than one of the
  44. ; *        directory types.
  45. ; *
  46. ; ****************************************
  47.  
  48. ;  MoviesUserData is the type used for user data in movie and track directories 
  49.  
  50. (defrecord MoviesUserData 
  51.    (size :SIGNED-LONG)          ;  size of this user data 
  52.    (udType :SIGNED-LONG)        ;  type of user data  
  53.    (data (:ARRAY :UNSIGNED-BYTE 1));  the user data 
  54.    )
  55.  
  56. (defrecord UserDataAtom 
  57.    (size :SIGNED-LONG)
  58.    (atomType :SIGNED-LONG)
  59.    (userData (:ARRAY :MOVIESUSERDATA 1))
  60.    )
  61.  
  62. ;  MoviesDataDescription tells us where the data for the movie or track lives.
  63. ;    The data can follow the directory, be in the datafork of the same file as the directory resource,
  64. ;    be in the resource fork of the same file as the directory resource, be in another file in the 
  65. ;    data fork or resource fork, or require a specific bottleneck to fetch the data. 
  66.  
  67. ; ***************************************
  68. ; *
  69. ; *   MediaDirectory information -
  70. ; *        The MediaDirectory is tightly coupled to the data.
  71. ; *
  72. ; ***************************************
  73.  
  74. ;  The SampleDescriptionTable holds the SampleDescriptions needed to decompress chunks given the
  75. ;    SampleDescriptionID. There is a table per Media. 
  76.  
  77. ; SampleDescription = RECORD
  78. ;     size        :    LONGINT;
  79. ;     dataFormat    :    LONGINT;
  80. ;     resvd1        :    LONGINT;
  81. ;     resvdA        :    INTEGER;
  82. ;     dataRefId    :    INTEGER;
  83. ; END;
  84. ; SampleDescriptionHandle = ^^SampleDescription;
  85.  
  86. (defrecord SampleDescriptionAtom 
  87.    (size :SIGNED-LONG)
  88.    (atomType :SIGNED-LONG)      ;  = 'stsd' 
  89.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  90.    (numEntries :SIGNED-LONG)
  91.    (sampleDescTable (:ARRAY :SAMPLEDESCRIPTION 1))
  92.    )
  93.  
  94. ;  TimeToSampleNum maps physical sample time to physical sample number. 
  95.  
  96. (defrecord TimeToSampleNum 
  97.    (sampleCount :SIGNED-LONG)
  98.    (sampleDuration :SIGNED-LONG)
  99.    )
  100.  
  101. (defrecord TimeToSampleNumAtom 
  102.    (size :SIGNED-LONG)
  103.    (atomType :SIGNED-LONG)      ;  = 'stts' 
  104.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  105.    (numEntries :SIGNED-LONG)
  106.    (timeToSampleNumTable (:ARRAY :TIMETOSAMPLENUM 1))
  107.    )
  108.  
  109. ;  SyncSamples is a list of the physical samples which are self contained. 
  110.  
  111. (defrecord SyncSampleAtom 
  112.    (size :SIGNED-LONG)
  113.    (atomType :SIGNED-LONG)      ;  = 'stss' 
  114.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  115.    (numEntries :SIGNED-LONG)
  116.    (syncSampleTable (:ARRAY :SIGNED-LONG 1))
  117.    )
  118.  
  119. (defrecord SampleToChunk 
  120.    (firstChunk :SIGNED-LONG)
  121.    (samplesPerChunk :SIGNED-LONG)
  122.    (sampleDescriptionID :SIGNED-LONG)
  123.    )
  124.  
  125. (defrecord SampleToChunkAtom 
  126.    (size :SIGNED-LONG)
  127.    (atomType :SIGNED-LONG)      ;  = 'stsc' 
  128.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  129.    (numEntries :SIGNED-LONG)
  130.    (sampleToChunkTable (:ARRAY :SAMPLETOCHUNK 1))
  131.    )
  132.  
  133. (defrecord ChunkOffsetAtom 
  134.    (size :SIGNED-LONG)
  135.    (atomType :SIGNED-LONG)      ;  = 'stco' 
  136.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  137.    (numEntries :SIGNED-LONG)
  138.    (chunkOffsetTable (:ARRAY :SIGNED-LONG 1))
  139.    )
  140.  
  141. (defrecord SampleSizeAtom 
  142.    (size :SIGNED-LONG)
  143.    (atomType :SIGNED-LONG)      ;  = 'stsz' 
  144.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  145.    (sampleSize :SIGNED-LONG)
  146.    (numEntries :SIGNED-LONG)
  147.    (sampleSizeTable (:ARRAY :SIGNED-LONG 1))
  148.    )
  149.  
  150. (defrecord ShadowSync 
  151.    (fdSampleNum :SIGNED-LONG)
  152.    (syncSampleNum :SIGNED-LONG)
  153.    )
  154.  
  155. (defrecord ShadowSyncAtom 
  156.    (size :SIGNED-LONG)
  157.    (atomType :SIGNED-LONG)
  158.    (flags :SIGNED-LONG)
  159.    (numEntries :SIGNED-LONG)
  160.    (shadowSyncTable (:ARRAY :SHADOWSYNC 1))
  161.    )
  162.  
  163. (defrecord SampleTableAtom 
  164.    (size :SIGNED-LONG)
  165.    (atomType :SIGNED-LONG)      ;  = 'stbl' 
  166.    (sampleDescription :SAMPLEDESCRIPTIONATOM)
  167.    (timeToSampleNum :TIMETOSAMPLENUMATOM)
  168.    (sampleToChunk :SAMPLETOCHUNKATOM)
  169.    (syncSample :SYNCSAMPLEATOM)
  170.    (sampleSize :SAMPLESIZEATOM)
  171.    (chunkOffset :CHUNKOFFSETATOM)
  172.    (shadowSync :SHADOWSYNCATOM)
  173.    )
  174.  
  175. (defrecord PublicHandlerInfo 
  176.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  177.    (componentType :SIGNED-LONG)
  178.    (componentSubType :SIGNED-LONG)
  179.    (componentManufacturer :SIGNED-LONG)
  180.    (componentFlags :SIGNED-LONG)
  181.    (componentFlagsMask :SIGNED-LONG)
  182.    (componentName (:ARRAY :UNSIGNED-BYTE 1))
  183.    )
  184.  
  185. (defrecord HandlerAtom 
  186.    (size :SIGNED-LONG)
  187.    (atomType :SIGNED-LONG)      ;  = 'hdlr' 
  188.    (hInfo :PUBLICHANDLERINFO)
  189.    )
  190.  
  191. (def-mactype :DATAREFATOM (find-mactype :SIGNED-LONG))
  192.  
  193. (defrecord DataInfoAtom 
  194.    (size :SIGNED-LONG)
  195.    (atomType :SIGNED-LONG)      ;  = 'dinf' 
  196.    (dataRef :SIGNED-LONG)
  197.    )
  198.  
  199. (defrecord RgnAtom 
  200.    (size :SIGNED-LONG)
  201.    (atomType :SIGNED-LONG)
  202.    (rgnSize :SIGNED-INTEGER)    ;  this is the contents of a region 
  203.    (rgnBBox :RECT)
  204.    (data (:ARRAY :UNSIGNED-BYTE 1))
  205.    )
  206.  
  207. (defrecord MatteCompressedAtom 
  208.    (size :SIGNED-LONG)
  209.    (atomType :SIGNED-LONG)
  210.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  211.    (matteImageDescription :IMAGEDESCRIPTION)
  212.    (matteData (:ARRAY :UNSIGNED-BYTE 1))
  213.    )
  214.  
  215. (defrecord MatteAtom 
  216.    (size :SIGNED-LONG)
  217.    (atomType :SIGNED-LONG)
  218.    (aCompressedMatte :MATTECOMPRESSEDATOM)
  219.    )
  220.  
  221. (defrecord ClippingAtom 
  222.    (size :SIGNED-LONG)
  223.    (atomType :SIGNED-LONG)
  224.    (aRgnClip :RGNATOM)
  225.    )
  226.  
  227. ; ***********************
  228. ; * Media Info Example Structures 
  229. ; ***********************
  230.  
  231. (defrecord VideoMediaInfoHeader 
  232.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  233.    (graphicsMode :SIGNED-INTEGER);  for QD - transfer mode 
  234.    (opColorRed :SIGNED-INTEGER) ;  opcolor for transfer mode 
  235.    (opColorGreen :SIGNED-INTEGER)
  236.    (opColorBlue :SIGNED-INTEGER)
  237.    )
  238.  
  239. (defrecord VideoMediaInfoHeaderAtom 
  240.    (size :SIGNED-LONG)          ;  size of Media info 
  241.    (atomType :SIGNED-LONG)      ;  = 'vmhd' 
  242.    (vmiHeader :VIDEOMEDIAINFOHEADER)
  243.    )
  244.  
  245. (defrecord VideoMediaInfo 
  246.    (size :SIGNED-LONG)          ;  size of Media info 
  247.    (atomType :SIGNED-LONG)      ;  = 'minf' 
  248.    (header :VIDEOMEDIAINFOHEADERATOM)
  249.    (dataHandler :HANDLERATOM)
  250.    (dataInfo :DATAINFOATOM)
  251.    (sampleTable :SAMPLETABLEATOM)
  252.    )
  253.  
  254. (defrecord SoundMediaInfoHeader 
  255.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  256.    (balance :SIGNED-INTEGER)
  257.    (rsrvd :SIGNED-INTEGER)
  258.    )
  259.  
  260. (defrecord SoundMediaInfoHeaderAtom 
  261.    (size :SIGNED-LONG)          ;  size of Media info 
  262.    (atomType :SIGNED-LONG)      ;  = 'vmhd' 
  263.    (smiHeader :SOUNDMEDIAINFOHEADER)
  264.    )
  265.  
  266. (defrecord SoundMediaInfo 
  267.    (size :SIGNED-LONG)          ;  size of Media info 
  268.    (atomType :SIGNED-LONG)      ;  = 'minf' 
  269.    (header :SOUNDMEDIAINFOHEADERATOM)
  270.    (dataHandler :HANDLERATOM)
  271.    (dataReference :SIGNED-LONG)
  272.    (sampleTable :SAMPLETABLEATOM)
  273.    )
  274.  
  275. (defrecord MediaInfo 
  276.    (size :SIGNED-LONG)
  277.    (atomType :SIGNED-LONG)
  278. ;  whatever data the media handler needs goes here 
  279.    )
  280.  
  281. ; **********************
  282. ; * Media Directory Structures 
  283. ; **********************
  284.  
  285. (defrecord MediaHeader 
  286.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  287.    (creationTime :SIGNED-LONG)  ;  seconds since Jan 1904 when directory was created 
  288.    (modificationTime :SIGNED-LONG);  seconds since Jan 1904 when directory was appended 
  289.    (timeScale :SIGNED-LONG)     ;  start time for Media (Media time) 
  290.    (duration :SIGNED-LONG)      ;  length of Media (Media time) 
  291.    (language :SIGNED-INTEGER)
  292.    (quality :SIGNED-INTEGER)
  293.    )
  294.  
  295. (defrecord MediaHeaderAtom 
  296.    (size :SIGNED-LONG)
  297.    (atomType :SIGNED-LONG)
  298.    (header :MEDIAHEADER)
  299.    )
  300.  
  301. (defrecord MediaDirectory 
  302.    (size :SIGNED-LONG)
  303.    (atomType :SIGNED-LONG)      ;  = 'mdia' 
  304.    (mediaHeader :MEDIAHEADERATOM);  standard Media information 
  305.    (mHandler :HANDLERATOM)
  306.    (MediaInfo :MEDIAINFO)
  307.    )
  308.  
  309. ; **********************
  310. ; * Track Structures 
  311. ; **********************
  312.  
  313. (defconstant $TrackEnable 1)
  314. (defconstant $TrackInMovie 2)
  315. (defconstant $TrackInPreview 4)
  316. (defconstant $TrackInPoster 8)
  317.  
  318. (defrecord TrackHeader 
  319.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  320.    (creationTime :SIGNED-LONG)  ;  seconds since Jan 1904 when directory was created 
  321.    (modificationTime :SIGNED-LONG);  seconds since Jan 1904 when directory was appended 
  322.    (trackID :SIGNED-LONG)
  323.    (reserved1 :SIGNED-LONG)
  324.    (duration :SIGNED-LONG)      ;  length of track (track time) 
  325.    (reserved2 :SIGNED-LONG)
  326.    (reserved3 :SIGNED-LONG)
  327.    (layer :SIGNED-INTEGER)
  328.    (alternateGroup :SIGNED-INTEGER)
  329.    (volume :SIGNED-INTEGER)
  330.    (reserved4 :SIGNED-INTEGER)
  331.    (matrix :MATRIXRECORD)
  332.    (trackWidth :SIGNED-LONG)
  333.    (trackHeight :SIGNED-LONG)
  334.    )
  335.  
  336. (defrecord TrackHeaderAtom 
  337.    (size :SIGNED-LONG)          ;  size of track header 
  338.    (atomType :SIGNED-LONG)      ;  = 'tkhd' 
  339.    (header :TRACKHEADER)
  340.    )
  341.  
  342. (defrecord EditListType 
  343.    (trackDuration :SIGNED-LONG)
  344.    (mediaTime :SIGNED-LONG)
  345.    (mediaRate :SIGNED-LONG)
  346.    )
  347.  
  348. (defrecord EditListAtom 
  349.    (size :SIGNED-LONG)
  350.    (atomType :SIGNED-LONG)      ;  = elst 
  351.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  352.    (numEntries :SIGNED-LONG)
  353.    (editListTable (:ARRAY :EDITLISTTYPE 1))
  354.    )
  355.  
  356. (defrecord EditsAtom 
  357.    (size :SIGNED-LONG)
  358.    (atomType :SIGNED-LONG)      ;  = edts 
  359.    (editList :EDITLISTATOM)
  360.    )
  361.  
  362. (defrecord TrackDirectory 
  363.    (size :SIGNED-LONG)
  364.    (atomType :SIGNED-LONG)      ;  = 'trak' 
  365.    (trackHeader :TRACKHEADERATOM);  standard track information 
  366.    (trackClip :CLIPPINGATOM)
  367.    (edits :EDITSATOM)
  368.    (media :MEDIADIRECTORY)
  369.    (userData :USERDATAATOM)     ;  space for extending with new data types 
  370.    )
  371.  
  372. (defrecord MovieHeader 
  373.    (flags :SIGNED-LONG)         ;  1 byte of version / 3 bytes of flags 
  374.    (creationTime :SIGNED-LONG)  ;  seconds since Jan 1904 when directory was created 
  375.    (modificationTime :SIGNED-LONG);  seconds since Jan 1904 when directory was appended 
  376.  
  377. ;  Time specifications 
  378.    (timeScale :SIGNED-LONG)
  379.    (duration :SIGNED-LONG)
  380.  
  381.    (preferredRate :SIGNED-LONG) ;  rate at which to play this movie 
  382.    (preferredVolume :SIGNED-INTEGER);  volume to play movie at 
  383.    (reserved1 :SIGNED-INTEGER)
  384.  
  385. ;  Graphics specifications 
  386.    (reserved2 :SIGNED-LONG)
  387.    (reserved3 :SIGNED-LONG)
  388.  
  389.    (matrix :MATRIXRECORD)
  390.  
  391.    (previewTime :SIGNED-LONG)   ;  time in track the proxy begins (track time) 
  392.    (previewDuration :SIGNED-LONG);  how long the proxy lasts (track time) 
  393.    (posterTime :SIGNED-LONG)    ;  time in track the proxy begins (track time) 
  394.    (selectionTime :SIGNED-LONG) ;  time in track the proxy begins (track time) 
  395.    (selectionDuration :SIGNED-LONG);  time in track the proxy begins (track time) 
  396.    (currentTime :SIGNED-LONG)   ;  time in track the proxy begins (track time) 
  397.    (nextTrackID :SIGNED-LONG)   ;  next value to use for a TrackID 
  398.    )
  399.  
  400. (defrecord MovieHeaderAtom 
  401.    (size :SIGNED-LONG)
  402.    (atomType :SIGNED-LONG)      ;  = 'mvhd' 
  403.    (header :MOVIEHEADER)
  404.    )
  405.  
  406. (defrecord trackDirectoryArray 
  407.    (TrackDirectory (:ARRAY :TRACKDIRECTORY 1))
  408.    )
  409.  
  410. (defrecord MovieDirectory 
  411.    (size :SIGNED-LONG)
  412.    (atomType :SIGNED-LONG)      ;  = 'moov' 
  413.    (header :MOVIEHEADERATOM)
  414.    (movieClip :CLIPPINGATOM)
  415. ;  Track Directories 
  416.    (track :TRACKDIRECTORYARRAY)
  417. ;  User data for Movie 
  418.    (userData :USERDATAATOM)     ;  space for user extensions 
  419.    )
  420.  
  421. ;  Movie formats and tags 
  422. ;  some system defined format IDs 
  423. (defconstant $MOVIE_TYPE :|moov|)
  424. (defconstant $TRACK_TYPE :|trak|)
  425. (defconstant $MEDIA_TYPE :|mdia|)
  426. (defconstant $VIDEO_TYPE :|vide|)
  427. (defconstant $SOUND_TYPE :|soun|)
  428.  
  429. ;  atom id's 
  430. (defconstant $MovieAID :|moov|)
  431. (defconstant $MovieHeaderAID :|mvhd|)
  432. (defconstant $ClipAID :|clip|)
  433. (defconstant $RgnClipAID :|crgn|)
  434. (defconstant $MatteAID :|matt|)
  435. (defconstant $MatteCompAID :|kmat|)
  436. (defconstant $TrackAID :|trak|)
  437. (defconstant $UserDataAID :|udta|)
  438. (defconstant $TrackHeaderAID :|tkhd|)
  439. (defconstant $EditsAID :|edts|)
  440. (defconstant $EditListAID :|elst|)
  441. (defconstant $MediaAID :|mdia|)
  442. (defconstant $MediaHeaderAID :|mdhd|)
  443. (defconstant $MediaInfoAID :|minf|)
  444. (defconstant $VideoMediaInfoHeaderAID :|vmhd|)
  445. (defconstant $SoundMediaInfoHeaderAID :|smhd|)
  446. (defconstant $GenericMediaInfoHeaderAID :|gmhd|)
  447. (defconstant $GenericMediaInfoAID :|gmin|)
  448. (defconstant $DataInfoAID :|dinf|)
  449. (defconstant $DataRefAID :|dref|)
  450. (defconstant $SampleTableAID :|stbl|)
  451. (defconstant $STSampleDescAID :|stsd|)
  452. (defconstant $STTimeToSampAID :|stts|)
  453. (defconstant $STSyncSampleAID :|stss|)
  454. (defconstant $STSampleToChunkAID :|stsc|)
  455. (defconstant $STShadowSyncAID :|stsh|)
  456. (defconstant $HandlerAID :|hdlr|)
  457. (defconstant $STSampleSizeAID :|stsz|)
  458. (defconstant $STChunkOffsetAID :|stco|)
  459. (defconstant $DataRefContainerAID :|drfc|)
  460.  
  461. ; $ENDC                         ;  UsingMoviesFormat 
  462.  
  463. ; $IFC NOT UsingIncludes
  464.  
  465. ; $ENDC
  466.  
  467. (export '($DATAREFCONTAINERAID $STCHUNKOFFSETAID $STSAMPLESIZEAID $HANDLERAID
  468.           $STSHADOWSYNCAID $STSAMPLETOCHUNKAID $STSYNCSAMPLEAID
  469.           $STTIMETOSAMPAID $STSAMPLEDESCAID $SAMPLETABLEAID $DATAREFAID
  470.           $DATAINFOAID $GENERICMEDIAINFOAID $GENERICMEDIAINFOHEADERAID
  471.           $SOUNDMEDIAINFOHEADERAID $VIDEOMEDIAINFOHEADERAID $MEDIAINFOAID
  472.           $MEDIAHEADERAID $MEDIAAID $EDITLISTAID $EDITSAID $TRACKHEADERAID
  473.           $USERDATAAID $TRACKAID $MATTECOMPAID $MATTEAID $RGNCLIPAID $CLIPAID
  474.           $MOVIEHEADERAID $MOVIEAID $SOUND_TYPE $VIDEO_TYPE $MEDIA_TYPE
  475.           $TRACK_TYPE $MOVIE_TYPE $TRACKINPOSTER $TRACKINPREVIEW $TRACKINMOVIE
  476.           $TRACKENABLE $KMOVIEVERSION))
  477. (provide-interface 'MoviesFormat)